package src.day20171117;

import java.io.*;

/**
 * Created by 林云志 on 2017/11/17.
 */
public class Test {
    public static void main(String[] args) {
        //1.字符流

        //1.1写文件
        String path = "E:\\hello.txt";
        try {
            BufferedWriter writer = new BufferedWriter(new FileWriter(path));
            writer.write("hello world!!");
            writer.newLine();

            writer.write("bye!!!");
        } catch (IOException e) {
            e.printStackTrace();
        }

        finally {

        }

        //2.字节流
        //写文件
        FileOutputStream fileOutputStream = null;
        try {
            fileOutputStream = new FileOutputStream(path);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }

        //10101100  - byte
        //每一次写的是一个或多个整数
        try {
        fileOutputStream.write(65);

        byte[] date = new byte[3];
        date[0] = 65;
            date[1] = 66;
            date[2] = 67;

        fileOutputStream.write(date);
    } catch (IOException e) {
        e.printStackTrace();
    }
    finally {
            try {
                fileOutputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
}
}
